//
//  XKAuthoErrorController.m
//  xk100
//
//  Created by xiaokang on 2017/7/5.
//  Copyright © 2017年 xiaokang. All rights reserved.
//

#import "XKAuthoErrorController.h"

@interface XKAuthoErrorController ()
@property (nonatomic, strong) UIButton *closeButton;
@property (nonatomic, strong) UILabel *tipLabel;
@end

@implementation XKAuthoErrorController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor yg_colorWithHexString:@"#f3f3f6"];
    
    _closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _closeButton.titleLabel.font = [UIFont systemFontOfSize:18*Scale_W];
    [_closeButton setTitle:@"关闭" forState:UIControlStateNormal];
    [_closeButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [_closeButton addTarget:self action:@selector(cancelAuthoLogonEnent:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_closeButton];
    [_closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.view).offset(-50*Scale_W);
        make.centerX.mas_equalTo(self.view);
    }];
    
    _tipLabel = [UILabel getLabWithText:_errorString textFont:Font_21 textColor:[UIColor blackColor] textAlignment:NSTextAlignmentCenter numberOfLines:0];
    [self.view addSubview:_tipLabel];
    [_tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.centerY.mas_equalTo(self.view);
        make.height.mas_equalTo(Main_Height*0.8);
        make.left.mas_equalTo(self.view).offset(20);
        make.right.mas_equalTo(self.view).offset(-20);
    }];
    
    _tipLabel.userInteractionEnabled = YES;
    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(copyText:)];
    [_tipLabel addGestureRecognizer:longPress];
    
}

#pragma mark -
- (void)copyText:(UILongPressGestureRecognizer *)longPress {
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = _errorString;
    [SVProgressHUD showInfoWithStatus:@"已复制文本!"];
}

#pragma mark - cancelAuthoLogonEnent
- (void)cancelAuthoLogonEnent:(UIButton *)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)setErrorString:(NSString *)errorString {
    _errorString = errorString;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}



@end
